/**
 */
package org.mro.grib.model.files.secondEdition.products.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.mro.grib.model.files.secondEdition.products.ProductDefinitionTemplate41;
import org.mro.grib.model.files.secondEdition.products.ProductsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product Definition Template41</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate41Impl#getTypeOfEnsembleForecast <em>Type Of Ensemble Forecast</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate41Impl#getPerturbationNumber <em>Perturbation Number</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate41Impl#getNumberOfForecastsInEnsemble <em>Number Of Forecasts In Ensemble</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductDefinitionTemplate41Impl extends ProductDefinitionTemplate40Impl implements ProductDefinitionTemplate41 {
	/**
	 * The default value of the '{@link #getTypeOfEnsembleForecast() <em>Type Of Ensemble Forecast</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeOfEnsembleForecast()
	 * @generated
	 * @ordered
	 */
	protected static final byte TYPE_OF_ENSEMBLE_FORECAST_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getTypeOfEnsembleForecast() <em>Type Of Ensemble Forecast</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeOfEnsembleForecast()
	 * @generated
	 * @ordered
	 */
	protected byte typeOfEnsembleForecast = TYPE_OF_ENSEMBLE_FORECAST_EDEFAULT;

	/**
	 * The default value of the '{@link #getPerturbationNumber() <em>Perturbation Number</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPerturbationNumber()
	 * @generated
	 * @ordered
	 */
	protected static final byte PERTURBATION_NUMBER_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getPerturbationNumber() <em>Perturbation Number</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPerturbationNumber()
	 * @generated
	 * @ordered
	 */
	protected byte perturbationNumber = PERTURBATION_NUMBER_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfForecastsInEnsemble() <em>Number Of Forecasts In Ensemble</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfForecastsInEnsemble()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfForecastsInEnsemble() <em>Number Of Forecasts In Ensemble</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfForecastsInEnsemble()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfForecastsInEnsemble = NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductDefinitionTemplate41Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ProductsPackage.Literals.PRODUCT_DEFINITION_TEMPLATE41;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getTypeOfEnsembleForecast() {
		return typeOfEnsembleForecast;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTypeOfEnsembleForecast(byte newTypeOfEnsembleForecast) {
		byte oldTypeOfEnsembleForecast = typeOfEnsembleForecast;
		typeOfEnsembleForecast = newTypeOfEnsembleForecast;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__TYPE_OF_ENSEMBLE_FORECAST, oldTypeOfEnsembleForecast, typeOfEnsembleForecast));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getPerturbationNumber() {
		return perturbationNumber;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPerturbationNumber(byte newPerturbationNumber) {
		byte oldPerturbationNumber = perturbationNumber;
		perturbationNumber = newPerturbationNumber;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__PERTURBATION_NUMBER, oldPerturbationNumber, perturbationNumber));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfForecastsInEnsemble() {
		return numberOfForecastsInEnsemble;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfForecastsInEnsemble(byte newNumberOfForecastsInEnsemble) {
		byte oldNumberOfForecastsInEnsemble = numberOfForecastsInEnsemble;
		numberOfForecastsInEnsemble = newNumberOfForecastsInEnsemble;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__NUMBER_OF_FORECASTS_IN_ENSEMBLE, oldNumberOfForecastsInEnsemble, numberOfForecastsInEnsemble));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__TYPE_OF_ENSEMBLE_FORECAST:
				return getTypeOfEnsembleForecast();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__PERTURBATION_NUMBER:
				return getPerturbationNumber();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				return getNumberOfForecastsInEnsemble();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__TYPE_OF_ENSEMBLE_FORECAST:
				setTypeOfEnsembleForecast((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__PERTURBATION_NUMBER:
				setPerturbationNumber((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				setNumberOfForecastsInEnsemble((Byte)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__TYPE_OF_ENSEMBLE_FORECAST:
				setTypeOfEnsembleForecast(TYPE_OF_ENSEMBLE_FORECAST_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__PERTURBATION_NUMBER:
				setPerturbationNumber(PERTURBATION_NUMBER_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				setNumberOfForecastsInEnsemble(NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__TYPE_OF_ENSEMBLE_FORECAST:
				return typeOfEnsembleForecast != TYPE_OF_ENSEMBLE_FORECAST_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__PERTURBATION_NUMBER:
				return perturbationNumber != PERTURBATION_NUMBER_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE41__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				return numberOfForecastsInEnsemble != NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (typeOfEnsembleForecast: "); //$NON-NLS-1$
		result.append(typeOfEnsembleForecast);
		result.append(", perturbationNumber: "); //$NON-NLS-1$
		result.append(perturbationNumber);
		result.append(", numberOfForecastsInEnsemble: "); //$NON-NLS-1$
		result.append(numberOfForecastsInEnsemble);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.products.IProductDefinition#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		super.initialise(buffer);
		typeOfEnsembleForecast = buffer.get();
		perturbationNumber = buffer.get();
		numberOfForecastsInEnsemble = buffer.get();
	}
	
} //ProductDefinitionTemplate41Impl
